package com.bw.http.http.okhttp

import androidx.core.app.ActivityCompat
import dagger.Module
import dagger.Provides
import dagger.hilt.InstallIn
import dagger.hilt.components.SingletonComponent
import okhttp3.OkHttpClient
import retrofit2.Retrofit
import javax.inject.Singleton

@Module//声明当前是一个hilt模块
@InstallIn(SingletonComponent::class) //声明当前类用的作用域是整个应用
object HttpHiltModel {

    @HttpClientAnnotation
    @Provides   //对外暴露
    @Singleton //声明当前对象是单例的
    fun providerHttpClient():OkHttpClient{
        return OKHttpClientManger.createOkHttpClient()
    }

    @HttpsClientAnnotation
    @Provides   //对外暴露
    @Singleton //声明当前对象是单例的
    fun providerHttpsClient():OkHttpClient{
        return OKHttpClientManger.createOkHttpClient()
    }

    @HttpRetrofitAnnotation
    @Provides   //对外暴露
    @Singleton //声明当前对象是单例的
    fun providerHttpRetrofit(@HttpClientAnnotation client: OkHttpClient):Retrofit{
        return RetrofitManger.getRetrofit(client)
    }

    @HttpsRetrofitAnnotation
    @Provides   //对外暴露
    @Singleton //声明当前对象是单例的
    fun providerHttpsRetrofit(@HttpsClientAnnotation client: OkHttpClient):Retrofit{
        return RetrofitManger.getRetrofit(client)
    }

}